<?php

namespace common\models\base;

use Yii;

/**
 * This is the model class for table "{{%edivi_order_divi}}".
 *
 * @property int $id
 * @property int $edivi_credit_order_id
 * @property int $created_at
 * @property string $req_data
 * @property string $loan_money 贷款金额合计
 * @property string $sf_money 首付
 * @property string $monthincome
 * @property string $market_id 附加费营销档案编号
 * @property string $finance_charge 附加费
 * @property string $guarantee_code 附加费担保合同/担保承诺函编号
 * @property string $maxmortrate 最高抵押率 (80%的话,传80,不传0.8)
 * @property string $mortvalue 抵押品价值
 * @property string $bailamount 保证总金额
 * @property string $insureamt 车损险投保金额
 *
 * @property EdiviCreditOrder $ediviCreditOrder
 */
class EdiviOrderDivi extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%edivi_order_divi}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['edivi_credit_order_id', 'created_at', 'req_data', 'loan_money', 'sf_money', 'monthincome'], 'required'],
            [['edivi_credit_order_id', 'created_at'], 'integer'],
            [['req_data'], 'string'],
            [['loan_money', 'sf_money', 'monthincome', 'finance_charge', 'maxmortrate', 'mortvalue', 'bailamount', 'insureamt'], 'number'],
            [['market_id', 'guarantee_code'], 'string', 'max' => 30],
            [['edivi_credit_order_id'], 'unique'],
            [['edivi_credit_order_id'], 'exist', 'skipOnError' => true, 'targetClass' => EdiviCreditOrder::className(), 'targetAttribute' => ['edivi_credit_order_id' => 'id']],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'edivi_credit_order_id' => Yii::t('app', 'Edivi Credit Order ID'),
            'created_at' => Yii::t('app', 'Created At'),
            'req_data' => Yii::t('app', 'Req Data'),
            'loan_money' => Yii::t('app', '贷款金额合计'),
            'sf_money' => Yii::t('app', '首付'),
            'monthincome' => Yii::t('app', 'Monthincome'),
            'market_id' => Yii::t('app', '附加费营销档案编号'),
            'finance_charge' => Yii::t('app', '附加费'),
            'guarantee_code' => Yii::t('app', '附加费担保合同/担保承诺函编号'),
            'maxmortrate' => Yii::t('app', '最高抵押率 (80%的话,传80,不传0.8)'),
            'mortvalue' => Yii::t('app', '抵押品价值'),
            'bailamount' => Yii::t('app', '保证总金额'),
            'insureamt' => Yii::t('app', '车损险投保金额'),
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getEdiviCreditOrder()
    {
        return $this->hasOne(EdiviCreditOrder::className(), ['id' => 'edivi_credit_order_id']);
    }
}
